#[derive(Debug)]
pub enum Gender {
    U = 0,
    M = 1,
    F = 2,
}

#[derive(Debug, Copy, Clone)]
pub struct UserId(pub u64);

#[derive(Debug, Copy, Clone)]
pub struct TopicId(pub u64);

#[derive(Debug)]
pub struct User {
    pub id: UserId,
    pub name: String,
    pub gender: Gender,
}

#[derive(Debug)]
pub struct Topic {
    pub id: TopicId,
    pub name: String,
    pub owner: UserId,
}

#[derive(Debug)]
pub enum Event {
    Join((UserId, TopicId)),
    Leave((UserId, TopicId)),
    Message((UserId, TopicId, String)),
}

// 模式匹配
fn process_event(event: &Event) {
    match event {
        Event::Join((uid, _tid)) => println!("user {:?} joined", uid),
        Event::Leave((uid, tid)) => println!("user{:?} left{:?}", uid, tid),
        Event::Message((_, _, msg)) => println!("broadcast:{}", msg),
    }
}

fn process_message(event: &Event) {
    if let Event::Message((_,_, msg)) = event {
        println!("broadcast:{}", msg)
    }
}